package me.zhengjie.util;

import com.alibaba.fastjson.JSON;
import me.zhengjie.annotation.Log;
import me.zhengjie.suli.inventory.domain.Inventory;
import me.zhengjie.suli.wcs.service.dto.AgvSendTask;
import me.zhengjie.suli.wcs.service.dto.AgvSendTaskDescribe;
import me.zhengjie.suli.wcs.service.dto.AgvSendTasks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
@Component
public class AgvTaskUtil {

    @Autowired
    private CommonUtil commonUtil;
    public static String outBoundTaskSendToAgv(List<Inventory> inventoryList){
        AgvSendTask agvSendTask = new AgvSendTask();
        agvSendTask.setTaskType("carry");
        agvSendTask.setGroupPriority(0);
        List<AgvSendTasks> tasks = new ArrayList<>();
        for (Inventory inventory : inventoryList) {

        }
        return null;
    }

    public String receiptTaskSendToAgv(String taskCode, String fromLocationCode, String toLocationCode){
        AgvSendTask task = new AgvSendTask();
        task.setTaskType("putaway");
        AgvSendTasks tasks = new AgvSendTasks();
        tasks.setTaskCode(taskCode);
        AgvSendTaskDescribe taskDescribe = new AgvSendTaskDescribe();
        taskDescribe.setToLocationCode(toLocationCode);
        taskDescribe.setFromLocationCode(fromLocationCode);
        tasks.setAgvSendTaskDescribe(taskDescribe);
        List<AgvSendTasks> tasksList = new ArrayList<>();
        tasksList.add(tasks);
        task.setTasks(tasksList);
        return commonUtil.httpPost("http://localhost:9046/task/caeate", JSON.toJSONString(task));
    }
}
